<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="订单单号">
              <a-input placeholder="请输入订单单号" v-model="queryParam.orderNo"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
          <a-form-item label="订单状态">
            <a-select placeholder="请选择订单状态" v-model="queryParam.status">
              <a-select-option  value="">请选择订单状态</a-select-option>
              <a-select-option  value="1">待付款</a-select-option>
              <a-select-option  value="2">待发货</a-select-option>
              <a-select-option  value="3">已发货</a-select-option>
              <a-select-option  value="4">已完成</a-select-option>
              <a-select-option  value="5">已关闭</a-select-option>
              <a-select-option  value="6">以评价</a-select-option>
            </a-select>
          </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
   <div class="table-operator">
     <a-button type="primary" icon="download" @click="handleExportXls('orders')">导出</a-button>
   </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">

          <a href="javascript:;" @click="handleDetails(record)">详情</a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <orders-modal ref="modalForm" @ok="modalFormOk"></orders-modal>
  </a-card>
</template>

<script>
  import OrdersModal from './modules/OrdersModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: "OrdersList",
    mixins:[JeecgListMixin],
    components: {
      OrdersModal
    },
    data () {
      return {
        description: '订单管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
		   {
            title: '订单单号',
            align:"center",
            dataIndex: 'orderNo'
           },
		   {
            title: '店铺名称',
            align:"center",
            dataIndex: 'shopName'
           },
		   {
            title: '金额',
            align:"center",
            dataIndex: 'payAmount',
              customRender: text => {
              return text / 100
            }
           },
		   {
            title: '订单状态',
            align:"center",
            dataIndex: 'status',
            customRender: text => {
              if(text == 1){
                return '待付款'
              }else if (text == 2){
                return '待发货'
              }else if (text == 3){
                return '已发货'
              } else if (text == 4){
                return '已完成'
              } else if (text == 5) {
                return '已关闭'
              }else{
                return '以评价'
              }
            }
           },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
      //admins/order/page",(访问该路径需要登录，修改成以下测试路径，勿忘)
          list: "/admins/order/seller/page",

          // delete: "/orders/delete",
          // deleteBatch: "/orders/deleteBatch",
          exportXlsUrl: "/admins/order/exportXls",
          importExcelUrl: "orders/importExcel",
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    handleDetails(record) {
      //路由传参
      this.$router.push({path:'/sellerorders/modules', query:{record}});
    },
  }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>